package com.chase.framerwork.common;

import com.chase.framerwork.entity.User;
import com.chase.framerwork.exception.SessionLostException;

/**
 * 全局信息
 * 
 * @Author Chase
 * @Date 2013-10-11
 */
public class Globle
{

	public static final String USER_SESSION = "user"; // userSession

	public static final String USERNAME_COOKIE = "userNameCookie"; // cookie用户名
	public static final String PASSWORD_COOKIE = "passwordCookie"; // cookie密码

	public static final int COOKIE_INVALID_TIME = 30 * 24 * 60 * 60; // cookie失效时间

	public static String CHARSET = "UTF-8"; // 字符集

	public static Integer MAX_PAGE_SIZE = 20;// 每页最大记录数限制

	public static String DATE_FROMART = "yyyy-MM-dd";// 日期格式
	public static String TIME_FROMART = "hh:mm:ss";// 时间格式

	public static String EXCEL_POSTFIX = ".xls"; // Excel文件后缀

	public static String SESSON_LOST = "sessionLost"; // Session超时跳转

	private static User user; // 登录后的用户

	public static User getUser()
	{
		if (user == null)
		{
			throw new SessionLostException();
		}
		return user;
	}

	public static void setUser(User user)
	{
		Globle.user = user;
	}

	public static Long getUserId()
	{
		return user.getId();
	}

	public static String getUserName()
	{
		return user.getUsername();
	}
}
